﻿using AutoMapper;
using Pay.DTO;
using Pay.IService;
using Pay.Core;
using Pay.Data;

namespace Pay.Service.AutoMapper {
	public class PostFeeMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public PostFeeMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<post_fee_dto, PostFee>()
				.ForMember(dest => dest.Province, src => src.MapFrom(c => c.province))
				.ForMember(dest => dest.StartPrice, src => src.MapFrom(c => c.start_price))
				.ForMember(dest => dest.StartWeight, src => src.MapFrom(c => c.start_weight))
                .ForMember(dest => dest.ContinuedWeight, src => src.MapFrom(c => c.continued_weight))
                  .ForMember(dest => dest.StartPriceUser, src => src.MapFrom(c => c.start_price_user))
                    .ForMember(dest => dest.ContinuedWeightUser, src => src.MapFrom(c => c.continued_weight_user))
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id));

			_cfg.CreateMap<PostFee,post_fee_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.province, src => src.MapFrom(c => c.Province))
				.ForMember(dest => dest.start_price, src => src.MapFrom(c => c.StartPrice))
                .ForMember(dest => dest.continued_weight, src => src.MapFrom(c => c.ContinuedWeight))
                .ForMember(dest => dest.continued_weight_user, src => src.MapFrom(c => c.ContinuedWeightUser))
                .ForMember(dest => dest.start_price_user, src => src.MapFrom(c => c.StartPriceUser))
                .ForMember(dest => dest.start_weight, src => src.MapFrom(c => c.StartWeight));
		}
	}
}
